package com.example.hangzhou.welbeing.mytestdemoapp.fragment;

import android.app.ActivityOptions;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v4.util.Pair;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;

import com.example.hangzhou.welbeing.mytestdemoapp.R;
import com.example.hangzhou.welbeing.mytestdemoapp.activity.AppBarActivity;
import com.example.hangzhou.welbeing.mytestdemoapp.activity.MyBloothDemoActivity;
import com.example.hangzhou.welbeing.mytestdemoapp.activity.ObserverActivity;
import com.example.hangzhou.welbeing.mytestdemoapp.activity.RecyclerViewActivity;
import com.example.hangzhou.welbeing.mytestdemoapp.activity.coordinateLayoutOneActivity;
import com.example.hangzhou.welbeing.mytestdemoapp.animation.animationActivity.AnimatedTransitionsfiveActivity;
import com.example.hangzhou.welbeing.mytestdemoapp.animation.animationActivity.TraditionalAnimationActivity;
import com.example.hangzhou.welbeing.mytestdemoapp.base.BaseFragment;

/**
 * 杭州惟君医疗科技有限公司14
 * Created by 20433 on 2018/2/27
 */

public class HomePagerFragment extends BaseFragment implements View.OnClickListener {

    private Button bt_01;
    private Button bt_02;
    private Button bt_03;
    private Button bt_04;
    private Button bt_05;
    private Button bt_06;
    private Button bt_07;
    private Button bt_08;
    private ImageView iv_my_cc;
    private ImageView iv_planet_one;
    Context mcontext;

    /**
     * @desc 当Fragment被添加到Activity的时候调用
     * @desc 调用一次
     */
    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        mcontext = context;
    }

    /**
     * @desc 在这里做一些注册活动 onCreate()
     * @desc 调用一次
     */
    @Override
    protected void registeredIntent() {

    }

    /**
     * @desc 填充Fragment的布局 onCreateView()
     * @desc 有可能调用多次
     */
    @Override
    protected View setFragmentView(LayoutInflater inflater, ViewGroup container) {
        View view = inflater.inflate(R.layout.fragment_home_pager, container, false);

        return view;
    }

    /**
     * @desc Fragment绘制view好后初始化 onViewCreated()
     * @desc 有可能调用多次
     */
    @Override
    protected void init(View view) {
        findView(view);
        showContent();
        loadingDate();
    }

    /**
     * @desc 加载数据
     */
    private void loadingDate() {
    }

    /**
     * @desc 加载内容数据
     */
    private void findView(View view) {
        bt_01 = view.findViewById(R.id.fragment_home_pager_effect_01);
        bt_02 = view.findViewById(R.id.fragment_home_pager_effect_02);
        bt_03 = view.findViewById(R.id.fragment_home_pager_effect_03);
        bt_04 = view.findViewById(R.id.fragment_home_pager_effect_04);
        bt_05 = view.findViewById(R.id.fragment_home_pager_effect_05);
        bt_06 = view.findViewById(R.id.fragment_home_pager_effect_06);
        bt_07 = view.findViewById(R.id.fragment_home_pager_effect_07);
        bt_08 = view.findViewById(R.id.fragment_home_pager_effect_08);
        iv_my_cc = view.findViewById(R.id.fragment_home_pager_effect_iv_my_cc);
        iv_planet_one = view.findViewById(R.id.fragment_home_pager_effect_iv_planet_one);

        bt_01.setOnClickListener(this);
        bt_02.setOnClickListener(this);
        bt_03.setOnClickListener(this);
        bt_04.setOnClickListener(this);
        bt_05.setOnClickListener(this);
        bt_06.setOnClickListener(this);
        bt_07.setOnClickListener(this);
        bt_08.setOnClickListener(this);

    }

    /**
     * @desc Fragment所在的Activity被启动  onActivityCreated();
     * @desc 有可能调用多次
     */
    @Override
    protected void startActivity() {

    }

    /**
     * @desc 弹出一些提示框  onStart()
     * @desc 有可能调用多次
     */
    @Override
    protected void PopupPrompts() {

    }

    /**
     * @desc 恢复Fragment可见获取到焦点  onResume()
     * @desc 有可能调用多次
     */
    @Override
    protected void fragmentResume() {

    }

    /**
     * @desc 关闭一些弹框  onPause()
     * @desc 有可能调用多次
     */
    @Override
    protected void CloseBounced() {

    }

    /**
     * @desc 关闭一些后台的操作  onStop()
     * @desc 有可能调用多次
     */
    @Override
    protected void CloseBackgroundOperation() {

    }

    /**
     * @desc 布局资源释放  onDestroyView()
     * @desc 有可能调用多次
     */
    @Override
    protected void LayoutResourceRelease() {

    }

    /**
     * @desc 解注册活动  onDestroy()
     * @desc 只调用一次
     */
    @Override
    protected void unRegisterIntent() {

    }

    /**
     * @desc 释放一些资源  onDetach()
     * @desc 只调用一次
     */
    @Override
    protected void releaseResources() {

    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.fragment_home_pager_effect_01:
                Intent intent = new Intent(mcontext, coordinateLayoutOneActivity.class);
                ActivityOptionsCompat transitionActivityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(), iv_my_cc, "shareNames_04");
                startActivity(intent,transitionActivityOptions.toBundle());
                break;
            case R.id.fragment_home_pager_effect_02:
//                Intent intent_01 = new Intent(mcontext, RecyclerViewActivity.class);
//                startActivity(intent_01);
                Intent intent_01 = new Intent(mcontext, RecyclerViewActivity.class);
                startActivity(intent_01, ActivityOptions.makeSceneTransitionAnimation(getActivity(), bt_02, "shareNames").toBundle());
                break;
            case R.id.fragment_home_pager_effect_03:
                Intent intent_012 = new Intent(mcontext, AnimatedTransitionsfiveActivity.class);
                startActivity(intent_012);
                break;
            case R.id.fragment_home_pager_effect_04:
                ActivityOptionsCompat compat_011 = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(),Pair.create(iv_my_cc, "shareNames_04"),Pair.create(iv_planet_one, "shareNames_05"), Pair.create(iv_planet_one, "shareNames_05") );
                ActivityCompat.startActivity(getActivity(), new Intent(mcontext, YouMengkActivity.class), compat_011.toBundle());

                break;
            case R.id.fragment_home_pager_effect_05:
                Intent intent_05 = new Intent(mcontext, MyBloothDemoActivity.class);
                startActivity(intent_05, ActivityOptions.makeClipRevealAnimation(view,0,0,view.getRight(),view.getBottom()).toBundle());
                // startActivity(intent_05, ActivityOptions.makeSceneTransitionAnimation(getActivity()).toBundle());
                //getActivity().overridePendingTransition(R.anim.scale_alpha, R.anim.set_one);
                break;
            case R.id.fragment_home_pager_effect_06:
                Intent intent_06 = new Intent(mcontext, ObserverActivity.class);
                startActivity(intent_06);
                break;
            case R.id.fragment_home_pager_effect_07:
                Intent intent_07 = new Intent(mcontext, TraditionalAnimationActivity.class);
                intent_07.putExtra("step", "第一");
                intent_07.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
                startActivity(intent_07);
                break;
            case R.id.fragment_home_pager_effect_08:
                Intent intent_08 = new Intent(mcontext, AppBarActivity.class);
                startActivity(intent_08);
                break;

        }
    }
}
